<%@page contentType="text/html; charset=utf-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>我的消息 - Fly社区</title>
    <link rel="stylesheet" type="text/css" href="../commons/iconfont/iconfont.css"/>
    <link rel="stylesheet" type="text/css" href="../commons/layui/css/layui.css"/>
    <link rel="stylesheet" type="text/css" href="../style/global.css"/>
    <script src="../js/jquery-3.3.1.min.js" type="text/javascript"></script>
    <script src="../commons/layui/layui.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<div class="fly-header layui-bg-black">
    <div class="layui-container"><a class="fly-logo" name="headlink" href="javascript:gotoIndex();"> <img
            src="../img/logo.png"
            alt="layui">
    </a>
        <ul class="layui-nav fly-nav layui-hide-xs">
            <li class="layui-nav-item layui-this"><a href="javascript:gotoIndex();"><i
                    class="iconfont icon-jiaoliu"></i>交流</a>
            </li>
            <li class="layui-nav-item"><a href="javascript:;"><i class="iconfont icon-chanpin"
                                                                 style="top: 1px;"></i>专区<span
                    class="layui-nav-more"></span></a>
                <dl class="layui-nav-child fly-nav-child layui-anim layui-anim-upbit">
                    <dd><a href="/vipclub/list/layuiadmin/">layuiAdmin</a></dd>
                    <hr>
                    <dd><a href="/vipclub/list/layim/">LayIM</a></dd>
                </dl>
            </li>
            <li class="layui-nav-item"><a href="http://www.layui.com/"><i class="iconfont icon-ui"></i>框架</a></li>
        </ul>
        <ul class="layui-nav fly-nav-user">
            <li class="layui-nav-item"><a class="fly-nav-avatar" href="https://fly.layui.com/user/"
                                          id="LAY_header_avatar">
                <cite class="layui-hide-xs nickName">${currentUser.nickName}</cite> <img
                    src="../upload/${currentUser.headImg}"> <span class="layui-nav-more"></span></a>
                <dl class="layui-nav-child layui-anim layui-anim-upbit">
                    <dd><a href="javascript:gotoUserCenter();">用户中心</a></dd>
                    <dd><a href="javascript:gotoUserAset();">基本设置</a></dd>
                    <hr>
                    <dd><a href="javascript:gotoUserMsg();">我的消息</a></dd>
                    <dd><a href="">已购产品</a></dd>
                    <dd><a href="javascript:gotoUserHomepage(${currentUser.id});">我的主页</a></dd>
                    <hr style="margin: 5px 0;">
                    <dd><a href="https://fly.layui.com/user/logout/" style="text-align: center;">退出</a></dd>
                </dl>
            </li>
            <span class="layui-nav-bar" style="left: 0px; top: 55px; width: 0px; opacity: 0;"></span>
        </ul>
    </div>
</div>
<div class="layui-container fly-marginTop fly-user-main">
    <ul class="layui-nav layui-nav-tree layui-inline" lay-filter="user">
        <li class="layui-nav-item"><a href="javascript:gotoUserHomepage(${currentUser.id});"> <i
                class="layui-icon"></i> 我的主页 </a></li>
        <li class="layui-nav-item"><a href="javascript:gotoUserCenter();"> <i class="layui-icon"></i> 用户中心 </a>
        </li>
        <li class="layui-nav-item "><a href="javascript:gotoUserAset();"> <i class="layui-icon"></i> 基本设置 </a></li>
        <li class="layui-nav-item "><a href="javascript:gotoUserInvitation();"> <i class="iconfont icon-tiezi"></i> 我的帖子
        </a></li>
        <li class="layui-nav-item layui-this"><a href="javascript:gotoUserMsg();"> <i class="layui-icon"></i> 我的消息 </a>
        </li>
        <li class="layui-nav-item "><a href="https://fly.layui.com/user/product/"> <i class="iconfont icon-chanpin"></i>
            已购产品 </a></li>
        <li class="layui-nav-item "><a href="https://fly.layui.com/user/extend/"> <i
                class="layui-icon layui-icon-component"></i>
            我的组件 </a></li>
        <span class="layui-nav-bar"></span>
    </ul>
    <div class="site-tree-mobile layui-hide"><i class="layui-icon"></i></div>
    <div class="site-mobile-shade"></div>
    <div class="fly-panel fly-panel-user" pad20="">
        <div class="layui-tab layui-tab-brief" lay-filter="user" id="LAY_msg" style="margin-top: 15px;">
            <button onclick="gotoDeleteAllReply();" class="layui-btn layui-btn-danger" id="LAY_delallmsg">全部删除</button>
            <div id="LAY_minemsg" style="margin-top: 10px;">
                <ul class="mine-msg dataList">

                </ul>
            </div>
        </div>
    </div>
</div>
<div class="fly-footer">
    <p><a href="http://fly.layui.com/">Fly 社区</a> 2019 © <a href="http://www.layui.com/">layui.com</a></p>
    <p><a href="http://fly.layui.com/jie/3147/" target="_blank">付费计划</a> <a href="https://fly.layui.com/extend/"
                                                                            target="_blank">组件平台</a>
        <a href="https://fly.layui.com/store/" target="_blank">模板市场</a> <a href="https://fly.layui.com/case/2019/"
                                                                           target="_blank">年度案例</a>
        <a href="http://fly.layui.com/jie/2461/" target="_blank">公众号</a></p>
    <div class="fly-union">
        <p style="display: block; margin-bottom: 10px;"><span>感谢以下平台提供云加速支持</span></p>
        <p><a href="https://console.upyun.com/register/?invite=SJ0wu6g2-" target="_blank" rel="nofollow"
              sponsor="upyun">
            <img src="../img/upyun.png"> </a> <a href="https://www.maoyuncloud.com/?from=layui"
                                                 target="_blank"
                                                 rel="nofollow" sponsor="maoyun"> <img
                src="../img/168_1559291577683_9348.png"> </a></p>
    </div>
</div>
<div class="layui-layer-move"></div>
<script>
    window.onload = function () {
        layui.use(['jquery', 'element'], function () {
            let element = layui.element,
                $ = layui.jquery;
            $.post({
                url: "../reply/findReplyByUserId",//对应controller的URL
                data:{"userId":${currentUser.id}},
                success: function (ret) {
                    let html = "";
                    let data = ret.data;
                    console.log(data);
                    if (data.length == 0) {
                        $("#LAY_msg").html("<h2>还没有过回复哦~<h2>");
                        return;
                    }
                    for (var i = 0; i < data.length; i++) {
                        html += '<li data-id="">\n' +
                            '<blockquote class="layui-elem-quote"><a href="javascript:gotoUserHomepage(' + data[i].userId + ');" target="_blank"><cite>' + data[i].nickName + '</cite></a>回答了您的求解<a\n' +
                            ' target="_blank" href="javascript:gotoReplyPost(' + data[i].postId + ');"><cite>' + data[i].replyContext + '</cite></a></blockquote>\n' +
                            '<p><span>' + data[i].createTime + '</span><a href="javascript:gotoDeleteReply(' + data[i].id + ');" class="layui-btn layui-btn-sm layui-btn-danger fly-delete">删除</a></p>\n' +
                            '</li>'
                    }
                    $(".dataList").append(html);
                }
            });
        });
    }

    function gotoDeleteReply(replyId) {
        $.post('../reply/delReplyByReplyId', {"replyId": replyId}, function (ret) {
            layer.msg(ret.msg);
            gotoUserMsg();
        });
    }

    function gotoDeleteAllReply() {
        $.post('../reply/delAllReply', function (ret) {
            layer.msg(ret.msg);
            gotoUserMsg();
        });
    }
</script>
<script src="../js/index.js" type="text/javascript" charset="utf-8"></script>
</body>
</html>
